package com.apollow.oschina.base;

import com.apollow.oschina.interf.OsChinaService;

import java.io.IOException;

import retrofit2.Call;
import retrofit2.Response;
import retrofit2.Retrofit;

/**
 * Created by Administrator on 2017/1/15.
 * 项目名:    OsChina
 * 包名:      com.apollow.oschina.base
 * 文件名:    BaseProtocol
 * 创建者:    LXF
 * 创建时间:   ${DATA}14:11
 * 描述:     TODO
 */
public abstract class BaseProtocol<T> {
    public Retrofit mRetrofit;
    public OsChinaService mService;
    public BaseProtocol(){
        mRetrofit=MyApp.mRetrofit;
        //获取Retrofit访问回来的接口;
        mService = mRetrofit.create(OsChinaService.class);
    }
    public T  getData(String...parms){//同步加载方式
        Call<T> blogInfo =getCall(parms);//子类请求网络的接口;
        try {
            Response<T> execute = blogInfo.execute();
            return execute.body();
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }

    protected abstract Call<T> getCall(String...parms);//可变参数;
}
